package com.gmrz.webauthn.common;


public class CBOREncodeValueWrapper {
    private Object obj;

    private Class<?> type;


    public CBOREncodeValueWrapper(Object obj, Class<?> type) {
        this.obj = obj;
        this.type = type;
    }

    public Object getObj() {
        return this.obj;
    }

    public void setObj(Object obj) {
        this.obj = obj;
    }

    public Class<?> getType() {
        return this.type;
    }

    public int hashCode() {
        int prime = 31;
        int result = 1;
        result = 31 * result + (this.obj == null ? 0 : this.obj.hashCode());
        return result;
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (this.obj == null) {
            return obj == null;
        }

        if (!(obj instanceof CBOREncodeValueWrapper)) {
            return false;
        }

        CBOREncodeValueWrapper other = (CBOREncodeValueWrapper) obj;


        if (this.type == String.class) {
            if (!((String) this.obj).equals((String) other.obj))
                return false;
        } else if (this.type == Integer.class) {
            if (!((Integer) this.obj).equals((Integer) other.obj))
                return false;
        } else if (this.type == Long.class) {
            if (!((Long) this.obj).equals((Long) other.obj)) {
                return false;
            }
        } else if (!this.obj.equals(obj)) {
            return false;
        }

        return true;
    }

    public void setType(Class<?> type) {
        this.type = type;
    }
}
